package com.jcw.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jcw.common.R;
import com.jcw.dto.SetmealDto;
import com.jcw.service.SetmealService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Resource
    private SetmealService setmealService;


    @GetMapping("/page")
    public R<Page> pageR(int page,int pageSize,String name){
        return setmealService.pagination(page,pageSize,name);
    }

    @PostMapping
    public R<String> add(@RequestBody SetmealDto setmealDto){
        return setmealService.add(setmealDto);
    }

    @GetMapping("/{id}")
    public R<SetmealDto> echo(@PathVariable Long id){
        return setmealService.echo(id);
    }

    @PutMapping
    public R<String> edit(@RequestBody SetmealDto setmealDto){
        return setmealService.edit(setmealDto);
    }

    @PostMapping("/status/{statusCode}")
    public R<String> editStatus(@PathVariable int statusCode,String ids){
        return setmealService.editStatus(statusCode,ids);
    }

    @DeleteMapping
    public R<String> delete(String ids){
        return setmealService.delete(ids);
    }

    @GetMapping("/list")
    public R<List> listR(String categoryId,Integer status){
        return setmealService.setmealList(categoryId,status);
    }


}
